package com.example.common.core.Controller;

import cn.hutool.core.collection.CollectionUtil;
import com.example.common.core.domin.R;
import com.example.common.core.domin.TableDataInfo;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class BaseController {

    public R<Void> toR(int rows) {
        return rows > 0 ? R.ok() : R.fail();
    }

    public R<Void> toR(boolean result) {
        return result ? R.ok() : R.fail();
    }


    public TableDataInfo getTableDataInfo(List<?> list) {
        //questionVOList == null || questionVOList.isEmpty()
        if(CollectionUtil.isEmpty(list)){
            return TableDataInfo.empty();
        }
//        long size = new PageInfo<>(list).getTotal(); //获取符合查询条件的数据总数
        return TableDataInfo.success(list, new PageInfo<>(list).getTotal());
    }

}
